package com.vicente.redisdemo.controller;

import com.alibaba.fastjson.JSONObject;
import com.vicente.redisdemo.service.RedisDemoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("redis")
public class RedisDemoController {

    @Autowired
    private RedisDemoService redisDemoService;

    @RequestMapping("getRedisCache")
    public String getRedisCache(@RequestBody JSONObject param){
        String key = param.getString("key");
        String redisByKey = redisDemoService.getRedisByKey(key);
        System.out.println("redis result:"+redisByKey);
        return redisByKey;
    }
}
